package com.mycompany.app.common.audit.modification.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

@Embeddable
public class AuditEmbeddedObject {
    @SuppressWarnings("unused")
    @Column(name = "create_by")
    private String createBy;

    @SuppressWarnings("unused")
    @Column(name = "last_modified_by")
    private String lastModifiedBy;

    @SuppressWarnings("unused")
    @Column(name = "create_date")
    private Date createDate;

    @SuppressWarnings("unused")
    @Column(name = "last_modified_date")
    private Date lastModifiedDate;

    @Override
    public String toString() {

        return ToStringBuilder.reflectionToString(this,
                ToStringStyle.SHORT_PREFIX_STYLE);
    }

    protected void setCreateInfo(String createUser) {

        this.createBy = createUser;
        this.createDate = new Date();
    }

    protected void setUpdateInfo(String updateUser) {

        this.lastModifiedBy = updateUser;
        this.lastModifiedDate = new Date();
    }
}
